package com.ooa;

/**
 * @author Li
 * @Date 2023/4/6 12:32
 */
public class Person {
    private String name;
    private int blood;
    private Attack attack;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getBlood() {
        return blood;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }



    public Person(String name, int blood, Attack attack) {
        this.name = name;
        this.blood = blood;
        this.attack = attack;
    }

    public void useAttack() {
        int damage = 0;
        if (attack instanceof PhyAttack) {
            damage = ((PhyAttack) attack).getDamage();
        } else if (attack instanceof MagAttack) {
            damage = ((MagAttack) attack).getDamage();
        }
        blood -= damage;
    }

}









